#include <iostream>

using namespace std;
void find(int *num, int n, int &minIndex, int &maxIndex);
int main()
{
  int t;
  cin >> t;
  while (t--)
  {
    int n;
    cin >> n;
    int *num = new int[n];
    int min, max, minIndex = 0, maxIndex = 0;
    for (int i = 0; i < n; i++)
    {
      cin >> num[i];
    }
    find(num, n, minIndex, maxIndex);
    cout << "min=" << num[minIndex] << " ";
    cout << "minindex=" << minIndex << endl;
    cout << "max=" << num[maxIndex] << " ";
    cout << "maxindex=" << maxIndex << endl;
    if (t != 0)
    {
      cout << endl;
      delete num;
    }
  }
  return 0;
}
void find(int *num, int n, int &minIndex, int &maxIndex)
{
  int min, max;
  minIndex = 0;
  maxIndex = 0;
  for (int i = 0; i < n; i++)
  {
    if (i == 0)
    {
      min = num[i];
      max = min;
    }
    if (num[i] > max)
    {
      max = num[i];
      maxIndex = i;
    }
    if (num[i] < min)
    {
      min = num[i];
      minIndex = i;
    }
  }
}